﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BuildPlannerLib.Buildings;
using BuildPlannerLib.Terran.Enums;

namespace BuildPlannerLib.Terran.Buildings
{
    // Derived class from Production for Barracks/Factory/Starport
    public class IndividualAddonBuilding : IndividualBuilding
    {
        // Addon enum field for addon type
        public AddonType AddonType;

        // Boolean property for addon production

        // Reactor = second unit being produced
        // TechLab = upgrade being produced

        private bool addonInUse;

        public bool AddonInUse
        {
            get { return addonInUse; }
            set { addonInUse = value; }
        }

        // Basic constructor
        public IndividualAddonBuilding()
        {
            InUse = false;
            AddonType = AddonType.None;
            AddonInUse = false;
        }

        // Overrides StartProduction() to account for Reactor production
        public override void StartProduction()
        {
            if (AddonType == AddonType.Reactor && InUse == true)
            {
                StartAddonProduction();
            }
            else
            {
                InUse = true;
            }
        }

        // Overrides FinishProduction() to account for Reactor production
        public override void FinishProduction()
        {
            if (AddonType == AddonType.Reactor && AddonInUse == true)
            {
                FinishAddonProduction();
            }
            else
            {
                InUse = false;
            }
        }

        // Adds a TechLab
        public void AddTechLab()
        {
            AddonType = AddonType.TechLab;
            InUse = true;
            AddonInUse = true;
        }

        // Adds a Reactor
        public void AddReactor()
        {
            AddonType = AddonType.Reactor;
            InUse = true;
            AddonInUse = true;
        }

        // Starts producing from the addon
        public void StartAddonProduction()
        {
            AddonInUse = true;
        }

        // Finishs producing from the addon
        public void FinishAddonProduction()
        {
            AddonInUse = false;
        }
    }
}
